AJAX_jquery ajax实现批量删除具体思路及代码,js页面jquery代码: 复制代码 代
var subChk = $("input[name='subChk']")
var checkedList = new Array();
window.location.reload();
alert("请选择至少一项!");
window.location.reload();
<th><input type="checkbox"/>全选</th>
public String deleteMore(HttpServletRequest request, HttpServletResponse response) {
java后台代码:
页面元素:
return;
复制代码 代码如下:
});}
$("#allChk").click(function() {
}
}
// 批量选择
/* 批量删除 */
$(document).ready(function() {
String[] item = items.split(",");
复制代码 代码如下:
});$("#allChk").prop("checked", subChk.length == subChk.filter(":checked").length ? true:false);
var checkedNum = $("input[name='subChk']:checked").length;
// 单选
js页面jquery代码:
$("#del_model").click(function() {
type: "POST",
}
success: function(result) {
<a href="#"><span>删除用户</span>
if(checkedNum == 0) {
});
}
<td><input type="checkbox" value="${user.id}"/></td>
url: "deletemore",
$("[name ='subChk']:checkbox").attr("checked", false);
checkedList.push($(this).val());
$("[name = 'items']:checkbox").attr("checked", false);
// 判断是否至少选择一项
data: {'delitems':checkedList.toString()},
复制代码 代码如下:
});userService.delete(Integer.parseInt(item[i]));
}
$.ajax({
@RequestMapping(value = "/deletemore", method = RequestMethod.POST)
subChk.click(function() {
String items = request.getParameter("delitems");
$("input[name='subChk']").prop("checked",this.checked);
$("input[name='subChk']:checked").each(function() {
if(confirm("确定要删除所选项目?")) {
for (int i = 0; i < item.length; i++) {
});
});
return "redirect:list";
回调函数,在请求完成后需要进行的操作:此处是把选中的checkbox去掉(因为是用到了freemarker的list循环,去掉是数据后checkbox序号变化,还有有相应未知的checkbox被选中,需要去掉)。
// 全选
相关热词: jquery
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jq/ui/5458.shtml
